import { createSlice } from '@reduxjs/toolkit';

/**store 默认值 */
export interface IInitialState {
  /**左侧菜单是否折叠 */
  collapse: boolean;
  /**菜单数据 */
  menuData: any[];
}

const initialState: IInitialState = {
  /**左侧菜单是否折叠 */
  collapse: false,
  /**菜单数据 */
  menuData: [],
};

const menuReducer = createSlice({
  name: 'menu.reducer',
  initialState,
  reducers: {
    /**设置左侧菜单是否折叠 */
    setCollapse: (state, action) => {
      state.collapse = action.payload;
    },
    /**设置菜单数据 */
    setMenuData: (state, action) => {
      state.menuData = action.payload;
    },
  },
});

export default menuReducer;
